<template>
    <div class="car-numbox">
        <van-stepper v-model="value" min="1"  integer 
        button-size="32px" input-width="40px" @change="updatecar" />
    </div>
</template>
<script>
    import {
        mapMutations
    } from 'vuex'
    export default {
        data() {
            return {
                value: 1
            }
        },
        created() {
            this.setValue()
        },
        methods: {
            ...mapMutations(['updateCarCount']),
            updatecar() {
                let obj = {
                    id: parseInt(this.id),
                    count: parseInt(this.value)
                }
                console.log(obj);
                this.updateCarCount(obj)
            },
            //
            setValue() {
                this.value = this.number
            }
        },
        props: ['number', 'id']
    }
</script>
<style lang="scss">
    .car-numbox {
        .van-stepper {
            display: flex;
            justify-content: flex-end;
            margin-top: 20px;
        }
    }
</style>